package com.ruoyi.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.ruoyi.system.domain.SProtectDevice;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 保护装置信息Mapper接口
 * 
 * @author ruoyi
 * @date 2023-07-05
 */
public interface SProtectDeviceMapper extends BaseMapper<SProtectDevice>
{

    @Select("SELECT GROUP_CONCAT(pd.protect_device_model) protect_device_model FROM s_protect_device pd " +
            "LEFT JOIN s_device_protect_device dpd on pd.id = dpd.protect_device_id " +
            "LEFT JOIN s_substation_device sd on sd.id = dpd.device_id " +
            "WHERE sd.id = #{deviceId}")
    String getProtectDeviceModelByDeviceId(String deviceId);

    @Select("SELECT pd.* FROM s_protect_device pd " +
            "LEFT JOIN s_device_protect_device dpd on pd.id = dpd.protect_device_id " +
            "LEFT JOIN s_substation_device sd on sd.id = dpd.device_id " +
            "WHERE sd.id = #{id}")
    List<SProtectDevice> getProtectDeviceList(String id);
}
